﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DES_Console
{
    class Program
    {
        static void Main(string[] args)
        {
        }

        BitArray IP(BitArray plText)
        {
            BitArray permArray = new BitArray(16);
            //1-4
            permArray[0] = plText[9];
            permArray[1] = plText[5];
            permArray[2] = plText[13];
            permArray[3] = plText[1];
            //5-8
            permArray[4] = plText[7];
            permArray[5] = plText[15];
            permArray[6] = plText[11];
            permArray[7] = plText[3];
            //9-12
            permArray[8] = plText[0];
            permArray[9] = plText[12];
            permArray[10] = plText[6];
            permArray[11] = plText[8];
            //13-16
            permArray[12] = plText[4];
            permArray[13] = plText[10];
            permArray[14] = plText[2];
            permArray[15] = plText[14];


            return permArray;
        }

        BitArray RevIP(BitArray permText)
        {
            BitArray permArray = new BitArray(16);
            //1-4
            permArray[0] = permText[8];
            permArray[1] = permText[3];
            permArray[2] = permText[14];
            permArray[3] = permText[7];
            //5-8
            permArray[4] = permText[12];
            permArray[5] = permText[1];
            permArray[6] = permText[10];
            permArray[7] = permText[4];
            //9-12
            permArray[8] = permText[11];
            permArray[9] = permText[1];
            permArray[10] = permText[13];
            permArray[11] = permText[6];
            //13-16
            permArray[12] = permText[9];
            permArray[13] = permText[3];
            permArray[14] = permText[15];
            permArray[15] = permText[5];


            return permArray;
        }

        BitArray LeftShift(BitArray ba, int bit)
        {
            int length = ba.Length;
            BitArray ret = new BitArray(length);

            int j = 0;

            for (int i = bit; j < length; i++)
            {
                ret[j++] = ba[i % length];
            }

            return ret;
        }

        BitArray SwitchArray(BitArray input)
        {
            int length = input.Length;
            BitArray sw = new BitArray(16);
            int j = 0;

            for (int i = 8; j < length; i++ )
            {
                sw[j++] = input[i % length];
            }

            return sw;
        }

        BitArray FK(BitArray IP, BitArray k)
        {
            BitArray[] t = Split_Block(IP);
            BitArray l = Xor(t[0),F
            BitArray combined = new BitArray(16);



            return combined;
        }
    }
}
